package com.ruoyi.notice.factory;

import com.ruoyi.common.utils.ApplicationContextUtil;
import com.ruoyi.notice.enums.SendTypeEnum;
import com.ruoyi.notice.service.ISendMessageService;
import com.ruoyi.notice.service.send.WeiXinQiYeSendMsgService;

import java.util.HashMap;
import java.util.Map;

public class SendMsgFactory {

    private static Map<String, Class<? extends ISendMessageService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(SendTypeEnum.WEIXIN_QIYE.getValue(), WeiXinQiYeSendMsgService.class);
    }

    public static ISendMessageService getService(String type){
        if (serviceMap.containsKey(type)){
            Class<? extends ISendMessageService> aClass = serviceMap.get(type);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
}
